<!--  -->
<template>
<div class="background">
<div class="container"></div>
<div class="win">{{msg}}</div>
  <div class="player">
    <div class="font0"><h1 class="font000">最终得分:</h1><h1 class="font00">{{score}}</h1></div>
    <div class="font1"><h1 class="font111">答对题数:</h1><h1 class="font11">{{rightCount}}</h1></div>
    <div class="font2"><h1 class="font222">答错题数:</h1><h1 class="font22">{{wrongCount}}</h1></div>
    <div class="font3"><h1 class="font222">未答题数:</h1><h1 class="font22">{{noChoiceCount}}</h1></div>
    <p class="font4">{{result}}</p>
  </div>
  <div class="player1" >
    <div class="player11">
      <img :src="avatarUrl" alt="" class="userinfo">
      <div>
        <p>{{userInfo.nickName}}</p>
        <p>积分：{{userScore}}</p>
     </div>
    </div>
  </div>
<div class="btn">
    <button @click="apply" class="btnstyle"><p class="font5">添加好友</p></button>
    <button class="btnstyle" @click="jmpToIndex"><p class="font5">返回主页</p></button>
</div>
</div>
</template>

<script>
import store from '../../utils/store'
import httpkit from '../../utils/http-kit'
export default {
  data () {
    return {
      msg: '',
      rightCount: 0,
      wrongCount: 0,
      score: 0,
      noChoiceCount: 0,
      userInfo: {},
      userScore: 0,
      avatarUrl: '/static/images/user.png',
      rivalInfo: null
    }
  },
  onLoad () {
    Object.assign(this.$data, this.$options.data())
  },
  components: {},

  computed: {
    result () {
      if (this.msg === 'win') {
        return '仍需努力,切莫骄傲'
      } else {
        return '革命尚未成功，同志们尚需努力'
      }
    }
  },

  mounted () {
    this.rightCount = store.state.result.rightCount
    this.wrongCount = store.state.result.wrongCount
    this.msg = store.state.result.resultType
    this.noChoiceCount = store.state.result.noChoiceCount
    this.score = store.state.resultScore
    this.userInfo = store.state.userInfo
    this.userScore = store.state.score
    this.avatarUrl = this.userInfo.avatarUrl
    this.rivalInfo = store.state.rivalInfo
    store.commit('resetRoomMessage', null)
    store.commit('resetRivalInfo', null)
  },

  methods: {
    jmpToIndex () {
      wx.redirectTo({
        url: '../index/main'
      })
    },
    apply () {
      var _this = this
      httpkit.get('/friend/addApply', {
        userId: store.state.userid,
        friendId: _this.rivalInfo.id
      }).then(
        wx.showToast({
          title: '申请成功',
          icon: 'success',
          duration: 2000
        })
      )
    }
  }
}
</script>
<style lang='scss' scoped>
@import "./style";
.background {
    display: flex;
    flex-direction: column;
    position:absolute;
    width: 100%;
    height: 100%;
    background-repeat: no-repeat;
    background-size: 100% 100%;
    background-image: url(https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=3059856828,1415522416&fm=26&gp=0.jpg);
}
.win {
    display: flex;
    align-items: center;
    justify-content: center;
    position:absolute;
    top: 10%;
    left: 25%;
    width: 50%;
    height: 8%;
    border-radius: 15px;
    background-color: black;
    color: aliceblue;
    letter-spacing: 5px;
    font-size: 25px;
    text-shadow: 3px 3px 5px rgb(72, 218, 255);
}
.container {
    position:absolute;
    top: 13%;
    left: 10%;
    width: 80%;
    height: 82%;
    border-radius: 15px;
    background-color:	#000000;
    opacity: 0.5;
    color: aliceblue;
    align-items: center;
    text-align: center;
    justify-content: center;
}
.player {
    display: flex;
    flex-direction: column;
    position:absolute;
    top: 44%;
    left: 10%;
    width: 80%;
    height: 40%;
    background-color:	#000000;
    opacity: 0.8;
    color: aliceblue;
    font-size: 15px;
    line-height: 400%;
}
.font0 {
    display: flex;
    flex-direction: row;
    border-radius: 15px;
    align-items: center;
    position: absolute;
    left: 15%;
    margin-top:15%;
    letter-spacing: 5px;
    height: 15%;
    width: 70%;
    background-color:	rgba(199, 103, 103, 0.498);
} 
.font00 {
    letter-spacing: 1px;
}
.font000 {
    margin-left: 10%;
}
.font1 {
    display: flex;
    flex-direction: row;
    border-radius: 15px;
    align-items: center;
    position: absolute;
    left: 15%;
    margin-top:30%;
    height: 15%;
    width: 70%;
    letter-spacing: 5px;
    background-color:	rgba(199, 103, 103, 0.498);
}
.font11 {
    letter-spacing: 1px;
}
.font111 {
    margin-left: 10%;
}
.font2 {
    display: flex;
    flex-direction: row;
    border-radius: 15px;
    align-items: center;
    position: absolute;
    left: 15%;
    margin-top:45%;
    height: 15%;
    width: 70%;
    letter-spacing: 5px;
    background-color:	rgba(199, 103, 103, 0.498);
}
.font22 {
    letter-spacing: 1px;
}
.font222 {
    margin-left: 10%;
}
.font3 {
    display: flex;
    flex-direction: row;
    border-radius: 15px;
    align-items: center;
    position: absolute;
    left: 15%;
    margin-top:60%;
    height: 15%;
    width: 70%;
    letter-spacing: 5px;
    background-color:	rgba(199, 103, 103, 0.498);
}
.font4 {
    display: flex;
    align-items: center;
    align-content: center;
    justify-content: center;
    justify-items: center;
    margin-top:75%;
    letter-spacing: 3px;
}
.font5 {
    display: flex;
    align-items: center;
    align-content: center;
    justify-content: center;
    justify-items: center;
    margin-top: 10%;
    letter-spacing: 3px;
}
.btn {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    position:absolute;
    left: 10%;
    top: 84%;
    width: 80%;
    height: 60px;
}
.btnstyle {
    display: inline-block;
    font-size: 15px;
    cursor: pointer;
    text-align: center;   
    text-decoration: none;
    outline: none;
    color: #fff;
    background-color: rgb(92, 126, 221);
    border: none;
    border-radius: 15px;
    box-shadow: 0 9px  rgb(59, 58, 58);
    width: 100px;
    height: 50px;
    letter-spacing: 3px;
}
.btnstyle:hover {background-color:rgb(92, 126, 221)}

.btnstyle:active {
  background-color: rgb(92, 126, 221);
  box-shadow: 0 5px rgb(116, 114, 114);
  transform: translateY(4px);
}
</style>